widget: Propagate display changes to the style context
authorMatthias Clasen <mclasen@redhat.com>
Sat, 6 Apr 2019 23:03:25 +0000 (23:03 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 6 Apr 2019 23:03:25 +0000 (23:03 +0000)
When a root is set on a widget, the style context may
already exist. We need to make sure that the style context
has the right display set.

This was showing up as "css spillover" in the inspector.

Closes: #https://gitlab.gnome.org/GNOME/gtk/issues/1817
gtk/gtkwidget.c

index aec86f331cffb717f359ebf798d23587b0d40f5d..ed0a21f5a7af74926ffa391b8106d1c143e7d7ae 100644 (file)
@@ -2953,6 +2953,9 @@ gtk_widget_root (GtkWidget *widget)
 
   priv->root = priv->parent->priv->root;
 
+  if (priv->context)
+    gtk_style_context_set_display (priv->context, gtk_root_get_display (priv->root));
+
   GTK_WIDGET_GET_CLASS (widget)->root (widget);
 
   g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_ROOT]);
@@ -2972,6 +2975,9 @@ gtk_widget_unroot (GtkWidget *widget)
 
   GTK_WIDGET_GET_CLASS (widget)->unroot (widget);
 
+  if (priv->context)
+    gtk_style_context_set_display (priv->context, gdk_display_get_default ());
+
   priv->root = NULL;
 
   g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_ROOT]);